package com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.Fragment_persenter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.PopupWindow;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter.DevicesManagerAdapter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter.MeetingAdapter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.custom_view.MyRecyclerView;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.dialog.BottomAnimDateDialog;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.fragment.fragment_contract.IMeetingContract;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.inter.IonClickedItemListenter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.utils.RecyclerViewUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/8/9.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class MeetingPersenter implements IMeetingContract.IMeetingPersenter {
    private IMeetingContract.IMeetingView mIMeetingView;
    private MeetingAdapter meetingAdapter;

    public MeetingPersenter(IMeetingContract.IMeetingView mIMeetingView) {
        this.mIMeetingView = mIMeetingView;
    }

    @Override
    public void showDateDilaog(Context mContext) {
        View view = View.inflate(mContext,R.layout.bottom_anim_date_dialog_layout, null);
        PopupWindow popup=new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
        popup.setAnimationStyle(R.style.ActionSheetDialogAnimation);
        popup.setOutsideTouchable(true);
        popup.setOutsideTouchable(true);
        popup.setTouchable(true);
        popup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        popup.setFocusable(true);
        popup.setTouchable(true);
        popup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        popup.showAtLocation(view, Gravity.BOTTOM,0,0);
    }

    @Override
    public void initTitle() {
        mIMeetingView.setTitle();
    }

    @Override
    public void initMyRecyclerview(MyRecyclerView mMyRecyclerView, Context mContext) {
        RecyclerViewUtils mRecyclerViewUtils =   new RecyclerViewUtils();
        meetingAdapter = new MeetingAdapter(mContext);
        mRecyclerViewUtils.initView(mMyRecyclerView,0,mContext, meetingAdapter);
        addAdapterDate();
        setDevicesManagerAdapterListener(meetingAdapter);
    }
    /**
     * @desc 向容器中添加数据
     * */
    private void addAdapterDate() {
        List<String> mlist = new ArrayList<>();
        for (int i = 0; i < 3; i++) {

            mlist.add("item----"+i);

        }
        meetingAdapter.AddItemDate(mlist);
    }
    /**
     * @desc 设置监听
     * */
    private void setDevicesManagerAdapterListener(MeetingAdapter managerAdapter) {
        managerAdapter.setmIonClickedItemListenter(new IonClickedItemListenter() {
            @Override
            public void onClickedItem(View view) {

            }

            @Override
            public void onClickedFist(int postion) {
                // 页面跳转
                mIMeetingView.toMettingListPager();
            }

            @Override
            public void onClickedSecond(int postion) {

            }
        });
    }
}
